package com.dq.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.http.HttpStatus;

import java.util.List;

/**
 * @创建人 gewenzhen
 * @创建时间 2019/7/17
 * @描述
 */
@Data
@ApiModel(value = "列表返回")
public class ListVo<T extends Object> extends Vo {
    /**
     * 返回数据量
     */
    @ApiModelProperty(value = "返回数据量")
    private long return_count;
    /**
     * 数据总量
     */
    @ApiModelProperty(value = "返回数据总量")
    private long total_count;

    @ApiModelProperty(value = "返回总值")
    private Object total_num;

    /**
     * 列表数据
     */
    @ApiModelProperty(value = "数据内容")
    private List<T> data;

    public ListVo(List<T> data) {
        super(HttpStatus.OK);
        this.setData(data);
        this.return_count = data.isEmpty() ? 0 : data.size();
    }

    /**
     * 分页使用
     */
    public ListVo(List<T> data, long total_count) {
        super(HttpStatus.OK);
        this.setData(data);
        this.return_count = data.isEmpty() ? 0 : data.size();
        this.total_count = total_count;
    }

    public ListVo(List<T> data, Object total_num, long total_count) {
        super(HttpStatus.OK);
        this.setData(data);
        this.return_count = data.isEmpty() ? 0 : data.size();
        this.total_count = total_count;
        this.total_num = total_num;
    }

}
